package com.example.myliwu;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class CourseAdapter extends BaseAdapter {
    private final List<String> mList;
    private final Context mContext;

    public CourseAdapter(List<String> mockList, Context mcontext) {
        this.mList = mockList;
        this.mContext = mcontext;

    }

    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup container) {
        String itemData = mList.get(position);
        Viewholder viewholder = null;
        if (convertView == null) {
            viewholder = new Viewholder();
            convertView=LayoutInflater.from(mContext).inflate(R.layout.item_layout,container,false);
            viewholder.textView = convertView.findViewById(R.id.item_TextView);
            convertView.setTag(viewholder);

        }else {
            viewholder = (Viewholder)convertView.getTag();
        }
        viewholder.textView.setText(itemData);
        return convertView;

    }

    class Viewholder {
        TextView textView;
    }

}



